package com.yoda.controller;



import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.yoda.constant.MessageConstant;
import com.yoda.dto.UserDto;
import com.yoda.dto.YddUserPageDTO;
import com.yoda.entity.YddUser;
import com.yoda.entity.YddUser;
import com.yoda.result.Result;
import com.yoda.service.IYddUserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author itcast
 * @since 2023-05-15
 */
@RestController
@RequestMapping("/ydd_user")
public class YddUserController {
    @Autowired
    private IYddUserService iYddUserService;
    /**
     * 根据id查询
     * @param id
     * @return
     */
    @GetMapping("rowInfo")
    public Result getById(@RequestParam Integer id){
        return iYddUserService.getById(id);
    }
    /**
     * 分页查询
     * @param pageDto
     * @return
     */
    @GetMapping("/list")
    public Result yddPage(YddUserPageDTO pageDto){

        return iYddUserService.yddPage(pageDto) ;
    }
    /**
     * 新增员工
     * @param yddUser
     * @return
     */

    @PostMapping("/add")
    public Result add(@RequestBody YddUser yddUser){
        iYddUserService.save(yddUser);
        return Result.success();
    }

    /**
     * 根据id删除员工
     * @param id
     * @return
     */
    @GetMapping("/del")
    public Result delete(@RequestParam Integer id){
        iYddUserService.removeById(id);
        return Result.success();
    }

    /**
     * 修改
     * @param userDTO
     * @return
     */
    @PostMapping("/update")
    public Result update(@RequestBody UserDto userDTO){

        return iYddUserService.update(userDTO);
    }

}

